﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RadioButtonList1.Items.Add("男");
                RadioButtonList1.Items.Add("女");
                DropDownList1.Items.Add("福建省");
                DropDownList1.Items.Add("广东省");
                DropDownList1.Items.Add("广西省");
                DropDownList2.Items.Add("福州市");
                DropDownList2.Items.Add("厦门市");
                DropDownList2.Items.Add("泉州市");
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string po = DropDownList1.SelectedValue;
            DropDownList2.Items.Clear();
            if (po == "福建省")
            {
                DropDownList2.Items.Add("福州市");
                DropDownList2.Items.Add("厦门市");
                DropDownList2.Items.Add("泉州市");
            }
            else if (po == "广东省")
            {
                DropDownList2.Items.Add("广州市");
                DropDownList2.Items.Add("深圳市");
                DropDownList2.Items.Add("茂名市");
            }
            else
            {
                DropDownList2.Items.Add("柳州市");
                DropDownList2.Items.Add("南宁市");
                DropDownList2.Items.Add("贵港市");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string ful = FileUpload1.FileName;
                if (ful.EndsWith(".jpg")|| (ful.EndsWith(".png")))
                {
                    string url = Server.MapPath("/img" + ful);
                    FileUpload1.SaveAs(url);
                    Image1.ImageUrl = "/img/" + ful;
                    Image1.Visible = true;
                }
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Label5.Text = $"姓名：{TextBox1.Text}；性别：{RadioButtonList1.SelectedValue}；爱好：{TextBox3.Text}；籍贯：{DropDownList1.SelectedValue}.{DropDownList2.SelectedValue}；其他信息：{TextBox4.Text}";
        }
    }
}